package pers.cj.pdos.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import pers.cj.pdos.entity.SaleAnalysis;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author chenj
 * @since 2020-03-25
 */
public interface SaleAnalysisMapper extends BaseMapper<SaleAnalysis> {
    Map getTotalData(@Param("companyId")String companyId,
                     @Param("storeId")String storeId,
                     @Param("houseId")String houseId,
                     @Param("date1") Date date1,
                     @Param("date2")Date date2);

    Map getHighGoods(@Param("companyId")String companyId,
                     @Param("storeId")String storeId,
                     @Param("houseId")String houseId,
                     @Param("date1") Date date1,
                     @Param("date2")Date date2);

    Map getHighCustom(@Param("companyId")String companyId,
                      @Param("storeId")String storeId,
                      @Param("houseId")String houseId,
                      @Param("date1") Date date1,
                      @Param("date2")Date date2);

    List<SaleAnalysis> listStoreData(@Param("companyId")String companyId,
                                          @Param("page") Integer page,
                                          @Param("limit") Integer limit,
                                          @Param("storeId")String storeId,
                                          @Param("houseId")String houseId,
                                          @Param("date1") Date date1,
                                          @Param("date2")Date date2);

    List<SaleAnalysis> listHouseData(@Param("companyId")String companyId,
                                          @Param("page") Integer page,
                                          @Param("limit") Integer limit,
                                          @Param("storeId")String storeId,
                                          @Param("houseId")String houseId,
                                          @Param("date1") Date date1,
                                          @Param("date2")Date date2);

    List<SaleAnalysis> listGoodsData(@Param("companyId")String companyId,
                                     @Param("page") Integer page,
                                     @Param("limit") Integer limit,
                                     @Param("storeId")String storeId,
                                     @Param("houseId")String houseId,
                                     @Param("customId")String customId,
                                     @Param("userId")String userId,
                                     @Param("date1") Date date1,
                                     @Param("date2")Date date2,
                                     @Param("typeId")String typeId,
                                     @Param("filterZero")Boolean filterZero,
                                     @Param("search")String search);

    Long countGoodsData(@Param("companyId")String companyId,
                        @Param("storeId")String storeId,
                        @Param("houseId")String houseId,
                        @Param("customId")String customId,
                        @Param("userId")String userId,
                        @Param("date1") Date date1,
                        @Param("date2")Date date2,
                        @Param("typeId")String typeId,
                        @Param("filterZero")Boolean filterZero,
                        @Param("search")String search);

    List<SaleAnalysis> listCustomData(@Param("companyId")String companyId,
                                            @Param("page") Integer page,
                                            @Param("limit") Integer limit,
                                            @Param("storeId")String storeId,
                                            @Param("houseId")String houseId,
                                            @Param("date1") Date date1,
                                            @Param("date2")Date date2,
                                            @Param("customTypeId")String customTypeId,
                                            @Param("filterZero")Boolean filterZero,
                                            @Param("search")String search);
    Long countCustomData(@Param("companyId")String companyId,
                       @Param("storeId")String storeId,
                       @Param("houseId")String houseId,
                       @Param("date1") Date date1,
                       @Param("date2")Date date2,
                       @Param("customTypeId")String customTypeId,
                       @Param("filterZero")Boolean filterZero,
                       @Param("search")String search);
    BigDecimal getTotalCustom(@Param("companyId")String companyId,
                              @Param("storeId")String storeId,
                              @Param("houseId")String houseId,
                              @Param("date1") Date date1,
                              @Param("date2")Date date2,
                              @Param("customTypeId")String customTypeId,
                              @Param("filterZero")Boolean filterZero,
                              @Param("search")String search);

    List<SaleAnalysis> listOrderData(@Param("companyId")String companyId,
                                          @Param("page") Integer page,
                                          @Param("limit") Integer limit,
                                          @Param("storeId")String storeId,
                                          @Param("houseId")String houseId,
                                          @Param("date1") Date date1,
                                          @Param("date2")Date date2);

    Long countOrderData(@Param("companyId")String companyId,
                        @Param("storeId")String storeId,
                        @Param("houseId")String houseId,
                        @Param("date1") Date date1,
                        @Param("date2")Date date2);

    List<SaleAnalysis> listGoodsDetailDataByOrder(@Param("companyId")String companyId,
                                                                  @Param("goodsId")String goodsId,
                                                                  @Param("page") Integer page,
                                                                  @Param("limit") Integer limit,
                                                                  @Param("storeId")String storeId,
                                                                  @Param("houseId")String houseId,
                                                                  @Param("date1") Date date1,
                                                                  @Param("date2")Date date2,
                                                                  @Param("search")String search);
    Long countGoodsDetailDataByOrder(@Param("companyId")String companyId,
                                     @Param("goodsId")String goodsId,
                                     @Param("storeId")String storeId,
                                     @Param("houseId")String houseId,
                                     @Param("date1") Date date1,
                                     @Param("date2")Date date2,
                                     @Param("search")String search);


    List<SaleAnalysis> listGoodsDetailDataByCustom(@Param("companyId")String companyId,
                                                                    @Param("goodsId")String goodsId,
                                                                    @Param("page") Integer page,
                                                                    @Param("limit") Integer limit,
                                                                    @Param("storeId")String storeId,
                                                                    @Param("houseId")String houseId,
                                                                    @Param("date1") Date date1,
                                                                    @Param("date2")Date date2,
                                                                    @Param("search")String search);
    Long countGoodsDetailDataByCustom(@Param("companyId")String companyId,
                                     @Param("goodsId")String goodsId,
                                     @Param("storeId")String storeId,
                                     @Param("houseId")String houseId,
                                     @Param("date1") Date date1,
                                     @Param("date2")Date date2,
                                     @Param("search")String search);

    /**
     * 获取商品的销售单的最大和最小时间
     * @param companyId
     * @param goodsId
     * @param storeId
     * @param houseId
     * @return
     */
    Map getMaxMinDate(@Param("companyId")String companyId,
                           @Param("goodsId")String goodsId,
                           @Param("customId")String customId,
                           @Param("storeId")String storeId,
                           @Param("houseId")String houseId);

    /**
     * 按照年份获取销售额
     * @param companyId
     * @param goodsId
     * @param storeId
     * @param houseId
     * @param date1
     * @param date2
     * @return
     */
    List<Map> getTotalByYear(@Param("companyId")String companyId,
                             @Param("goodsId")String goodsId,
                             @Param("customId")String customId,
                             @Param("userId")String userId,
                             @Param("storeId")String storeId,
                             @Param("houseId")String houseId,
                             @Param("date1") Date date1,
                             @Param("date2")Date date2);

    /**
     * 按照月份获取销售额
     * @param companyId
     * @param goodsId
     * @param storeId
     * @param houseId
     * @param date1
     * @param date2
     * @return
     */
    List<Map> getTotalByMonth(@Param("companyId")String companyId,
                              @Param("goodsId")String goodsId,
                              @Param("customId")String customId,
                              @Param("userId")String userId,
                              @Param("storeId")String storeId,
                              @Param("houseId")String houseId,
                              @Param("date1") Date date1,
                              @Param("date2")Date date2);

    /**
     * 按照日获取销售额
     * @param companyId
     * @param goodsId
     * @param storeId
     * @param houseId
     * @param date1
     * @param date2
     * @return
     */
    List<Map> getTotalByDate(@Param("companyId")String companyId,
                             @Param("goodsId")String goodsId,
                             @Param("customId")String customId,
                             @Param("userId")String userId,
                             @Param("storeId")String storeId,
                             @Param("houseId")String houseId,
                             @Param("date1") Date date1,
                             @Param("date2")Date date2);
}


